var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BulletMgr = require("BulletMgr");
var $2BundleManager = require("BundleManager");
var $2ExcelManager = require("ExcelManager");
var $2KDefine = require("KDefine");
var $2Zombie = require("Zombie");
var $2DataManager = require("DataManager");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_Zombie2 = /* */function (_r$default) {
  babel_inherits(u, _r$default);
  var _super104 = babel_createSuper(u);
  function u() {
    var _this244;
    babel_classCallCheck(this, u);
    _this244 = _super104.apply(this, arguments);
    _this244.skinID = 1;
    _this244.ani = {
      move: "zou",
      attack: "kenyao",
      dead: "die"
    };
    return _this244;
  }
  babel_createClass(u, [{
    key: "time",
    get() {
      return this._time;
    },
    set(e) {
      this._time = e;
      this.dragon.timeScale = this.time;
      0 != this.time || this.skinID;
    }
  }, {
    key: "hp",
    get() {
      return this._hp;
    },
    set(e) {
      this._hp = e;
    }
  }, {
    key: "equipHp",
    get() {
      return this._equipHp;
    },
    set(e) {
      e < 0 && (e = 0);
      this._equipHp = e;
      if (this.equipHp / this.allequipHp < .75 && this.equipHp / this.allequipHp >= .5 && 2 != this.skinID) {
        this.skinID = 2;
      } else if (this.equipHp / this.allequipHp < .5 && this.equipHp / this.allequipHp >= .25 && 3 != this.skinID) {
        this.skinID = 3;
      } else {
        this.equipHp / this.allequipHp < .25 && this.equipHp / this.allequipHp >= 0 && 4 != this.skinID && (this.skinID = 4);
      }
    }
  }, {
    key: "daiji",
    value: function daiji() {
      this.node.getChildByName("zombie").getComponent(sp.Skeleton).setAnimation(0, this.ani.move, true);
    }
  }, {
    key: "hurt",
    value: function hurt(e, t, a) {
      var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
      var s = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
      if (this.inUse) {
        if ("" != t && t) {
          var _e132 = $2BulletMgr.default.instance().getEffect(t);
          _e132.scale = a;
          _e132.parent = this.node;
          _e132.x = n;
          _e132.y = s;
          var _o4 = _e132.getComponent(sp.Skeleton);
          _o4.setAnimation(0, "newAnimation", false);
          _o4.setCompleteListener(function () {
            _o4.setCompleteListener(null);
            _e132.scale = 1;
            $2BulletMgr.default.instance().removeEffect(_e132);
          });
        }
        if (this.equipHp > 0) {
          if (this.equipHp >= e) {
            this.equipHp -= e;
          } else {
            this.hp -= e - this.equipHp;
            this.equipHp = 0;
          }
        } else {
          this.hp -= e;
        }
        if (this.hp <= 0) {
          this.setState($2KDefine.State.dead);
        } else {
          this.flash = .7;
        }
        if (this.equipHp <= 0 && $2DataManager.default.instance.is_bowling) {
          this.hp = 0;
          this.setState($2KDefine.State.dead);
        }
      }
    }
  }, {
    key: "setSkin",
    value: function setSkin() {
      var _this245 = this;
      var e = $2ExcelManager.ExcelMgr.instance.GetExcelObject($2ExcelManager.TableName.zombieTable)[this.id];
      this.skinID = 1;
      if ($2BundleManager.default.instance.getBundleRes("Spine", "zombie/" + e.dragonName + "/" + e.dragonName, sp.SkeletonData)) {
        this.dragon.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "zombie/" + e.dragonName + "/" + e.dragonName, sp.SkeletonData);
        this.dragon.defaultSkin = e.defaultSkin;
        this.dragon.setSkin(e.defaultSkin);
      } else {
        $2BundleManager.default.instance.loadBundleRes("Spine", "zombie/" + e.dragonName + "/" + e.dragonName, sp.SkeletonData, function () {
          _this245.dragon.skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "zombie/" + e.dragonName + "/" + e.dragonName, sp.SkeletonData);
          _this245.dragon.defaultSkin = e.defaultSkin;
          _this245.dragon.setSkin(e.defaultSkin);
        });
      }
    }
  }, {
    key: "moveAni",
    value: function moveAni() {
      babel_get(babel_getPrototypeOf(u.prototype), "moveAni", this).call(this);
    }
  }, {
    key: "attackAni",
    value: function attackAni() {
      babel_get(babel_getPrototypeOf(u.prototype), "attackAni", this).call(this);
    }
  }, {
    key: "deadAni",
    value: function deadAni() {
      babel_get(babel_getPrototypeOf(u.prototype), "deadAni", this).call(this);
    }
  }]);
  return u;
}($2Zombie.default);
def_Zombie2 = cc__decorate([ccp_ccclass], def_Zombie2);
exports.default = def_Zombie2;